package dao.tables;

import java.sql.Date;

import javax.swing.ListModel;

public class MEMBRE extends PERSONNE {
    private RESPONSABILITE responsabilite = new RESPONSABILITE();
    private INSTRUMENT[] listInstrument = new INSTRUMENT[0];
    private SPECIALITE[] listSpecialite = new SPECIALITE[0];
    private GROUPE[] listGroupe = new GROUPE[0];

    public MEMBRE() {
	super();
    }

    public MEMBRE(long id, String nom, String prenom, String civilite,
	    Date dateDeNaissance, RESPONSABILITE responsabilite,
	    INSTRUMENT[] listInstrument, SPECIALITE[] listSpecialite,
	    GROUPE[] listGroupe) {
	super(id, nom, prenom, civilite, dateDeNaissance);
	this.setResponsabilite(responsabilite);
	this.setListInstrument(listInstrument);
	// this.setListSpecialite(listSpecialite);
	this.setListGroupe(listGroupe);
    }

    public MEMBRE(PERSONNE pers, RESPONSABILITE responsabilite,
	    INSTRUMENT[] listInstrument, SPECIALITE[] listSpecialite,
	    GROUPE[] listGroupe) {
	super(pers.getId(), pers.getNom(), pers.getPrenom(),
		pers.getCivilite(), pers.getDateDeNaissance());
	this.setResponsabilite(responsabilite);
	this.setListInstrument(listInstrument);
	// this.setListSpecialite(listSpecialite);
	this.setListGroupe(listGroupe);
    }

    @Override
    public String getValue() {
	return this.getNom();
    }

    // RESPONSABILITE
    public void setResponsabilite(RESPONSABILITE responsabilite) {
	this.responsabilite = responsabilite;
    }

    public RESPONSABILITE getResponsabilite() {
	return responsabilite;
    }

    // INSTRUMENT
    public INSTRUMENT[] getListInstrument() {
	return this.listInstrument;
    }

    public void setListInstrument(INSTRUMENT[] listInstrument) {
	this.listInstrument = listInstrument;
    }

    public void setListInstrument(ListModel listModel) {
	this.listInstrument = new INSTRUMENT[listModel.getSize()];
	for (int i = 0; i < this.listInstrument.length; i++)
	    this.listInstrument[i] = (INSTRUMENT) listModel.getElementAt(i);
    }

    // SPECIALITE
    public SPECIALITE[] getListSpecialite() {
	return this.listSpecialite;
    }

    public void setListSpecialite(SPECIALITE[] specialites) {
	this.listSpecialite = specialites;
    }

    public void setListSpecialite(ListModel listModel) {
	this.listSpecialite = new SPECIALITE[listModel.getSize()];
	for (int i = 0; i < this.listSpecialite.length; i++)
	    this.listSpecialite[i] = (SPECIALITE) listModel.getElementAt(i);
    }

    // GROUPE
    public GROUPE[] getListGroupe() {
	return this.listGroupe;
    }

    public void setListGroupe(GROUPE[] list) {
	this.listGroupe = list;
    }

    public void setListGroupe(ListModel listModel) {
	this.listGroupe = new GROUPE[listModel.getSize()];
	for (int i = 0; i < this.listGroupe.length; i++)
	    this.listGroupe[i] = (GROUPE) listModel.getElementAt(i);
    }

    @Override
    public String toString() {
	String str = "PERSONNE {\n";
	str += "\tID : " + this.getId() + "\n";
	str += "\tNOM : " + this.getNom() + "\n";
	str += "\tPRENOM : " + this.getPrenom() + "\n";
	str += "\tCIVILITE : " + this.getCivilite() + "\n";
	str += "\tDATE DE NAISSANCE : " + this.getDateDeNaissance() + "\n";
	str += "\tRESPONSABILITE : " + this.getResponsabilite() + "\n";
	str += "\tINSTRUMENTS : " + this.getListInstrument() + "\n";
	str += "\tSPECIALITES : " + this.getListSpecialite() + "\n}\n";
	str += ".....................................................\n";
	return str;
    }
}
